//
//  QXNavigationController.m
//  JYQX
//
//  Created by Hayder on 2018/8/20.
//  Copyright © 2018年 Hayder. All rights reserved.
//

#import "HHNavigationController.h"

#define TitleColor [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1]

@interface HHNavigationController ()<UIGestureRecognizerDelegate>

@end

@implementation HHNavigationController


- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.navigationBarHidden = YES;
    
    self.interactivePopGestureRecognizer.delegate = self;
}

/**
 *  重写这个方法目的：能够拦截所有push进来的控制器
 *
 *  @param viewController 即将push进来的控制器
 */
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (self.childViewControllers.count > 0) { // 如果push进来的不是第一个控制器
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
}


-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    
     return self.childViewControllers.count > 1;
}

/**
 用来修改导航栏颜色
 */
- (UIViewController *)childViewControllerForStatusBarStyle {
    return self.topViewController;
}

/**
 用来隐藏状态栏
 */
- (BOOL)prefersStatusBarHidden {
    return self.topViewController.prefersStatusBarHidden;
}

@end
